#include<bits/stdc++.h>
#define uup_(x) ((int)(x==int(x)?x:x+1))
using namespace std;
struct node{
    int d0,v0,a_v;
    void read(){
        scanf("%d%d%d",&d0,&v0,&a_v);
    }
    bool fixS(int pos,int limv){
        int s=pos-d0;
        return (v0*v0+2*a_v*s)>limv*limv;
    }
    double reachV(int v){
        return (double)(v*v-v0*v0)/(2.0*a_v)+((double)(v*v-v0*v0)/(2.0*a_v)==(int)(v*v-v0*v0)/(2.0*a_v))*(a_v>0?1:-1)+d0;
    }
}car[100010];
struct line_{
    int pos,LR;//L0R1
    bool operator <(const line_ &A)const{
        if(pos!=A.pos) return pos<A.pos;
        return LR<A.LR;
    }
}all[200010];
int toL[1000010],toR[1000010],allpos;
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T,n,m,L,limV,i,inp,ans1;
    scanf("%d",&T);
    while(T--){
        ans1=0,allpos=0;
        memset(toL,-1,sizeof toL);
        memset(toR,-1,sizeof toR);
        scanf("%d%d%d%d",&n,&m,&L,&limV);
        for(i=1;i<=n;i++) car[i].read();
        for(i=1;i<=m;i++){
            scanf("%d",&inp);
            toL[inp]=toR[inp]=inp;
        }
        for(i=1;i<=L;i++)
            if(toL[i]!=i) toL[i]=toL[i-1];
        for(i=L-1;i>=0;i--)
            if(toR[i]!=i) toR[i]=toR[i+1];
        for(i=1;i<=n;i++){
            if(car[i].a_v>=0){
                if(car[i].fixS(toL[L],limV)){
                    ans1++;
                    if(car[i].v0>limV){
                        all[++allpos]={toR[car[i].d0],0};
                        all[++allpos]={toL[L],1};
                        //printf("A1  %d: %d %d\n",i,all[allpos-1].pos,all[allpos].pos);
                    }
                    else{
                        all[++allpos]={toR[uup_(car[i].reachV(limV))],0};
                        all[++allpos]={toL[L],1};
                        //printf("A2  %d: %d %d\n",i,all[allpos-1].pos,all[allpos].pos);
                    }
                }
            }else{
                if(car[i].fixS(toR[car[i].d0],limV)){
                    ans1++;
                    all[++allpos]={toR[car[i].d0],0};
                    all[++allpos]={toL[min(L,int(car[i].reachV(limV)))],1};
                    //printf("B  %d: %d %d\n",i,all[allpos-1].pos,all[allpos].pos);
                }
            }
        }
        printf("%d ",ans1);
        sort(all+1,all+allpos+1);
        //for(i=1;i<=allpos;i++) printf("%d%c%c",all[i].pos,(all[i].LR?'R':'L')," \n"[i==allpos]);
        int cntt=0,alcnt=0,ans2=0;
        for(i=1;i<=allpos;i++){
            if(!all[i].LR) cntt++;
            else if(cntt)
                alcnt+=cntt,ans2++,cntt=0;
        }
        printf("%d\n",m-ans2);
    }
    return 0;
}
